// pages/docChat/docChat.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        chatList: [],
        value: 0,
        postValue: 0,
    },

    chat() {
        console.log(111)
        wx.navigateTo({
            url: '../sendMessage/sendMessage',
          })
    },

    rrate(item) {
        console.log(item.currentTarget.dataset.item.chatId)
        console.log(this.data.postValue)
        wx.request({
            url: 'https://118.31.170.229:5001/api/CjwChatList/UserRate',
            method: 'post',
            data: {
                chatId:item.currentTarget.dataset.item.chatId,
                rate:this.data.postValue
            },
            success: (res) => {
                let userInfo = wx.getStorageSync('userInfo')
        wx.request({
            url: 'https://118.31.170.229:5001/api/CjwChatList/UserGetMessage?openId='+userInfo.openId ,
            method: 'get',
            success: (res) => {
                this.setData({
                    chatList: res.data
                })
            }
          })
            }
          })
    },

    onChange1(val) {
        console.log(val.detail)
        this.setData({
            postValue:val.detail
        })
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let userInfo = wx.getStorageSync('userInfo')
        wx.request({
            url: 'https://118.31.170.229:5001/api/CjwChatList/UserGetMessage?openId='+userInfo.openId ,
            method: 'get',
            success: (res) => {
                this.setData({
                    chatList: res.data
                })
            }
          })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
        
        let userInfo = wx.getStorageSync('userInfo')
        wx.request({
            url: 'https://118.31.170.229:5001/api/CjwChatList/UserGetMessage?openId='+userInfo.openId ,
            method: 'get',
            success: (res) => {
                console.log(res)
                this.setData({
                    chatList: res.data
                })
            }
          })
    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})